package demo.dcs.util;


import demo.dcs.TraceGenerater2;
import demo.java.lang.management.vo.XdcsConstants;
import demo.java.lang.management.vo.XmlySpan;

/**
 * @author dbwind.liu
 *
 */

public class CallRelInfoUtil {

    public static String getClientApp(){
        XmlySpan xmlySpan = TraceGenerater2.getTracer().getParentSpan();
        if(xmlySpan == null){
            return null;
        }

        String clientApp = xmlySpan.getProps().get(XdcsConstants.X_B3_CLIENT_APP_ID);

        return clientApp;
    }

    public static String getClientIp(){
        XmlySpan xmlySpan = TraceGenerater2.getTracer().getParentSpan();
        if(xmlySpan == null){
            return null;
        }

        String clientIp = xmlySpan.getProps().get(XdcsConstants.X_B3_CLIENT_IP);

        return clientIp;
    }

    public static String getClientServiceId(){
        XmlySpan xmlySpan = TraceGenerater2.getTracer().getParentSpan();
        if(xmlySpan == null){
            return null;
        }

        String clientServiceId= xmlySpan.getProps().get(XdcsConstants.X_B3_SERVICE_ID);

        return clientServiceId;
    }

    public static String getServerApp(){
        XmlySpan xmlySpan = TraceGenerater2.getTracer().getParentSpan();
        if(xmlySpan == null){
            return null;
        }

        String serverApp = xmlySpan.getProps().get(XdcsConstants.X_B3_SERVER_APP);

        return serverApp;
    }

    public static String getServerIp(){
        XmlySpan xmlySpan = TraceGenerater2.getTracer().getParentSpan();
        if(xmlySpan == null){
            return null;
        }

        String serverIp = xmlySpan.getProps().get(XdcsConstants.X_B3_SERVER_IP);

        return serverIp;
    }

    public static String getServerServiceId(){
        XmlySpan xmlySpan = TraceGenerater2.getTracer().getParentSpan();
        if(xmlySpan == null){
            return null;
        }

        String serverServiceId= xmlySpan.getProps().get(XdcsConstants.X_B3_SERVER_SERVICEID);

        return serverServiceId;
    }
}
